#pragma once

///////////////////////////////////////////////////////////////////////////
//																		 //
//	Author:		Michael Mozdzierz										 //
//	Date:		12/17/2014												 //
//	Purpose:	Define a class that manages and updates the game over	 //
//				a network												 //
//																		 //
///////////////////////////////////////////////////////////////////////////

#include "NetworkDefs.h"
#include <WinSock2.h>
#pragma comment(lib, "Ws2_32.lib")

struct IPAddress;

// Singleton that manages game data over a network
class NetworkManager
{
	// represents the connection to the server
	SOCKET server = INVALID_SOCKET;

	char serverBuffer[DEFAULT_BUFFER_LENGTH];

	bool connectedToGame = false;

	NetworkManager(void);
	~NetworkManager(void);
public:
	// connects to the server with the provided ip address
	void ConnectToSession(IPAddress ipAddress);

	// disconnects from the current session (if any)
	void DisconnectSession(void);

	// update the network manager
	void Update(float dt);

	// get the singleton instance
	static NetworkManager* GetInstance(void)
	{
		static NetworkManager instance;

		return &instance;
	}
};